package com.couldsail.takeaway.controller.user;

import com.couldsail.takeaway.common.result.Result;
import com.couldsail.takeaway.pojo.entity.Categories;
import com.couldsail.takeaway.service.CategoriesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(tags = "分类")
@RestController("CategoriesController")
@RequestMapping("/user/categories")
@RequiredArgsConstructor
@CrossOrigin(origins = "*") // 允许所有来源的请求跨域
public class CategoriesController {
    @Autowired
    private CategoriesService categoriesService;
    @GetMapping
    @ApiOperation("查询分类列表")
    public Result<List<Categories>> GetCategories(Integer id){
        log.info("用户查询分类{}",id);
        List<Categories> allList = categoriesService.getAllList(id);
        return Result.success(allList);
    }
}
